<template>
    <div>
        <v-toolbar fixed>
            <v-spacer></v-spacer>
            <v-toolbar-title style="margin-left:0px;">身份验证</v-toolbar-title>
            <v-spacer></v-spacer>
        </v-toolbar>
        <br />
        <br />
        <v-content class="scrollContent" v-if="isLogin">
            <v-container fluid>
                <v-layout row wrap>
                    <v-flex xs12>
                        <v-text-field v-model="uname" label="用户名" :rules="unameRules"></v-text-field>
                    </v-flex>
                    <v-flex xs12>
                        <v-text-field v-model="password" type="password" label="密码" :rules="passwordRules"></v-text-field>
                    </v-flex>
                    <v-flex xs8 offset-xs2>
                        <v-btn @click="btnLogin" block color="success">登录</v-btn>
                    </v-flex>
                </v-layout>
            </v-container>
        </v-content>
    </div>
</template>

<script>
//import httpUtils from "../utils/httpUtils";
import { userData } from "../utils/commonUtils";
export default {
    name: "Login",
    components: {},
    data() {
        return {
            uname: "",
            password: "",
            unameRules: [
                v => !!v || "请填写用户名",
                v => !/[^a-zA-Z0-9]/.test(v) || "用户名不能包含特殊字符"
            ],
            passwordRules: [v => !!v || "请填写密码"],
            isLogin: true,
            alertCheck: false,
            checking: true
        };
    },
    methods: {
        btnLogin() {
            // httpUtils
            //   .getJSONWithUrl("/f/postLogin", {
            //     userName: this.uname,
            //     passWord: this.password
            //   })
            //   .then(data => {
            //     userData.uid = data.uid;
            //     userData.userToken = data.userToken;
            //     userData.userInfo = data.userInfo;
            //     userData.userRole = data.userRole;
            //     this.$router.push("/home");
            //   })
            //   .catch(err => {
            //     alert(err);
            //   });

            userData.uid = 123;
            userData.userToken = "123";
            userData.userInfo = { name: "test" };
            userData.userRole = "管理员";
            this.$router.push('/home')

        },

    }
};
</script>
